package com.silverbox.shopper.mapper;

import java.util.List;
import java.util.Map;

import com.silverbox.shopper.entity.extend.ShopAddressInfo;
import org.apache.ibatis.annotations.Param;

import com.silverbox.shopper.entity.Shopper;
import com.silverbox.shopper.entity.extend.ShopperActivities;
import com.silverbox.shopper.entity.extend.ShopperAndParent;
import com.silverbox.shopper.entity.extend.ShopperInfo;

public interface ShopperMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(Shopper record);

    int insertSelective(Shopper record);

    Shopper selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(Shopper record);

    int updateByPrimaryKey(Shopper record);
    
    /**
     * 根据子店铺id获取主店铺和子店铺信息
     * @param id
     * @return
     */
    ShopperAndParent getShopperAndParent(Integer id);
    
    /**
     * 根据口碑门店id获取店铺活动信息
     * @param shopId
     * @param nowDate
     * @return
     */
    List<ShopperActivities> getShopperActivities(@Param("shopId")String shopId,@Param("nowDate")String nowDate);

    /**
     * 获取店铺信息
     * @param storeId
     * @param nowDate
     * @return
     */
	ShopperInfo getShopperInfo(@Param("storeId")Integer storeId, @Param("nowDate")String nowDate);

	/**
	 * 判断商家是否开通了扫呗支付
	 * @param storeId
	 * @param shopperId
	 * @return
	 */
	Integer isSaobei(@Param("storeId")Integer storeId, @Param("shopperId")Integer shopperId);
	
	/**
	 * 判断商家是否开通了蚂蚁支付
	 * @param storeId
	 * @param shopperId
	 * @return
	 */
	Integer isWxPay(@Param("storeId")Integer storeId, @Param("shopperId")Integer shopperId);
	
	/**
	 * 根据店铺ID更新out_index/in_index
	 * @param storeId
	 * @return
	 */
	int updateIndex(@Param("storeId")Integer storeId);
	
	/**
	 * 根据店铺ID 订单类型 index值更新out_index/in_index
	 * @param storeId
	 * @param orderType
	 * @param index
	 * @return
	 */
	int updateIndexs(@Param("storeId") Integer storeId ,@Param("orderType") Integer orderType,@Param("index") Integer index);
	
	/**
	 * 获取 in_index/out_index 、shop_hours值
	 * @param storeId
	 * @param orderType
	 * @return
	 */
	Shopper selectIndex(@Param("storeId") Integer storeId ,@Param("orderType") Integer orderType);

    /**
     * 获取距离当前位置最近的店铺
     * @param shopperId
     * @param storeId
     * @param citycode
     * @param nick
     * @return
     */
    List<ShopAddressInfo> findAllStoreByShopIdAndCityCode(@Param("shopperId") Integer shopperId, @Param("storeId") Integer storeId,@Param("cityCode") String citycode, @Param("nick") String nick);

    /**
     * 获取当前时段 门店是否有优惠
     * @param storeId
     * @param shopId
     * @return
     */
    Integer isStoreDiscount(@Param("shopperId") Integer storeId,@Param("shopId") Integer shopId);

    List<Map<String, Object>> getStoreLogoListByStoreIds(@Param("storeIds") List<Long> storeIds);

    Long getShopIdByAppId(@Param("appId") String appId);

    List<Long> getShopIdListByAppId(@Param("appId") String appId);

    List<Map<String, Object>> getMiniConfigChannelAndMiniTypeKey(@Param("appId") String appId);

    List<Long> getShopIdListByConfigKey(@Param("configKeys") List<String> configKeys,@Param("appId") String appId);
}